/**
 * 
 */
package neptune.manager.validator.rules.netif;

import neptune.manager.model.topology.NetworkInterface;
import neptune.manager.utils.Logger.MessageType;
import neptune.manager.validator.ValidatorResult;
import neptune.manager.validator.ValidatorRule;
import neptune.manager.validator.Validator.Status;

/**
 * @author Roberto Bifulco [info@RobertoBifulco.it] [RobertoBifulco.it]
 * 
 */
public class OneIPAddressRule extends ValidatorRule<NetworkInterface> {

	@Override
	public String getName() {
		return "OneIPAddressRule";
	}

	@Override
	protected ValidatorResult validationAlgorithm(NetworkInterface toValidate,
			ValidatorResult result) {

		if (toValidate.getIpAddresses().length != 1) {
			result.setStatus(Status.ERROR);
			result.getLog().addMessage(
					"Definition of 1 ip address is required, number of defined "
							+ "ip addresses: "
							+ toValidate.getIpAddresses().length,
					MessageType.ERROR);
		}

		return result;
	}

}
